using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EZCRS.HCMS.DataAcl;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Web;


namespace EZCRS.HCMS.Web.manage.group
{
    public partial class group_add : ManageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckModule(23);

            BtnDel.Attributes.Add("onclick", "javascript:return confirm('"+Resources.Site.SystemConfirmDelete+"');");

            if (!Page.IsPostBack)
            {
                CFun.SetListControl(rblcity, DataAcl.Common.YesOrNo(), "1");
                CFun.SetListControl(rblshowtop, DataAcl.Common.YesOrNo(), "1");

                CFun.SetListControl(ddlclass, new BllHotelUtil().Group_list(), "0");
            }

            int GId = CFun.RequestNumber("id");

            if (GId != 0)
            {
                gid.Value = GId.ToString();
                DataRow drgroup = new BllHotelUtil().Group_Item(GId.ToString());
                ddlclass.SelectedValue = drgroup["parentid"].ToString();
                tbxname.Text = drgroup["classname"].ToString();
                tbxnameen.Text = drgroup["classname_e"].ToString();
                tbxreadme.Text = drgroup["readme"].ToString();
                rblcity.SelectedValue = (drgroup["iselite"].ToString() == "true") ? "1" : "0";
                rblshowtop.SelectedValue = (drgroup["showontop"].ToString() == "true") ? "1" : "0";
            }
            else
                BtnDel.Visible = false;
        }

        
        protected void BtnAdd_Click(object sender, EventArgs e)
        {
            if (new BllHotelUtil().Group_Add(ddlclass.SelectedValue, tbxname.Text, tbxnameen.Text, tbxreadme.Text, rblcity.SelectedValue, rblshowtop.SelectedValue, DropDownList2.SelectedValue,gid.Value))
                Response.Write(CFun.AlertMeg(Resources.Site.SystemAddSuccess, "non", "group_add.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.AlertErrorMsg, "back", ""));
        }

        protected void BtnDel_Click(object sender, EventArgs e)
        {
            if (new BllHotelUtil().Group_Del(gid.Value))
                Response.Write(CFun.AlertMeg(Resources.Site.SystemDeleteSuccess, "non", "group_list.aspx"));
            else
                Response.Write(CFun.AlertMeg(Resources.Site.SystemError, "back", ""));
        }
    }
}
